package bean;


import java.sql.Timestamp;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
public class Formata {
	  public static  final int NOVO=1;
	  public static  final int EXPORTAR=2;
	  public static  final int REPLICAR=3;
	  public static  final int VOLTAR=4;
	  public static  final int AVANCAR=5;
	  public static  final int CANCELAR=6;
	  public static  final int OK=7;
	  
	private static final NumberFormat formato = NumberFormat.getInstance(Locale.getDefault());
		
	
	
	public static String getDoubleFormatLocal(double valor) {
		 try {
			 if(valor==0){
				 return  "0,00" ; 
			 }else{
		     return  formato.format(valor) ;
			 }
		      
		    } catch (Exception e) {
		    	
		    	  return null;
		    }
		
	}
	
	public static int parseInt(String valor) {
		 try {
			 if(valor!= null && !valor.isEmpty()){
				 return  Integer.parseInt(valor) ; 
			 }else{
		     return  0 ;
			 }
		      
		    } catch (NumberFormatException e) {
		    	e.printStackTrace();
		    	  return 0;
		    }
		
	}
	
	public static double getDoubleFormatPadrao(String valorDouble) {
		 try {
			 
	
		     return formato.parse(valorDouble).doubleValue()  ;
		      
		    } catch (Exception e) {
		    	e.printStackTrace();
		    	  return 0.0;
		    }
		
	}
	
	public static int convetNmeroInt(String valor) {
		 try {
			
	
		     return  Integer.parseInt(valor.replaceAll("[\\D]",""))  ;
		      
		    } catch (Exception e) {
		    	e.printStackTrace();
		    	  return 0;
		    }
		
	}
	
	public static String formatDatadd_mm_aaaaa(Timestamp data) {
		 try {
			 String datd ="";
			 if (data != null) {
				 datd = new SimpleDateFormat("dd/MM/yyyy").format(data);
				
			}
	
		     return datd;
		      
		    } catch (Exception e) {
		    	e.printStackTrace();
		    	  return  "";
		    }
		
	}
	



}
